package pers.xiaojun.boot.module.system.controller.user.vo.user;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import pers.xiaojun.boot.common.enums.GenderEnum;
import pers.xiaojun.boot.common.validation.constraints.InEnum;
import pers.xiaojun.boot.common.validation.group.CreateGroup;

import java.util.Set;

/**
 * 用户创建/修改实体
 *
 * @author xiaojun
 * @since 2025-11-05
 */
@Schema(description = "用户创建/修改实体-VO")
@Data
@Accessors(chain = true)
public class UserSaveReqVO {

    @Schema(description = "用户编号", example = "1")
    private Long id;

    @Schema(description = "用户账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "xiaojun")
    @NotBlank(message = "用户账号不能为空")
    @Pattern(regexp = "^[a-zA-Z0-9]+$", message = "用户账号由 数字、字母 组成")
    @Size(min = 4, max = 30, message = "用户账号长度为 4-30 个字符")
    private String username;

    @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "XIAO鈞i")
    @NotBlank(message = "用户昵称不能为空")
    @Size(max = 30, message = "用户昵称长度不能超过30个字符", groups = CreateGroup.class)
    private String nickname;

    @Schema(description = "备注", example = "我是一个用户")
    private String remark;

    @Schema(description = "部门编号", example = "1")
    private Long deptId;

    @Schema(description = "岗位编号数组", example = "{1,2,3}")
    private Set<Long> postIds;

    @Schema(description = "用户邮箱", example = "junlanok@163.com")
    @Email(message = "邮箱格式不正确")
    @Size(max = 50, message = "邮箱长度不能超过 50 个字符")
    private String email;

    @Schema(description = "手机号码", example = "18860888888")
    private String mobile;

    @Schema(description = "用户性别，参见 GenderEnum 枚举类", example = "1")
    @InEnum(value = GenderEnum.class, message = "性别必须为 {value}")
    private Integer sex;

    @Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png")
    private String avatar;

    @Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
    @NotBlank(message = "密码不能为空", groups = CreateGroup.class)
    @Length(min = 4, max = 16, message = "密码长度为 4-16 位", groups = CreateGroup.class)
    private String password;


}
